<template>
  <div>
    <el-button type="primary" @click="add">添加</el-button>
    <list-vue @willEdit="willEdit"></list-vue>
    <form-vue :info="info" ref="form"></form-vue>
    <!-- 分页 -->
    <el-pagination
      layout="prev, pager, next"
      :total="total"
      background
      :page-size="size"
      @current-change="changePage"
    >
    </el-pagination>
  </div>
</template>
<script>
import listVue from "./components/list.vue";
import formVue from "./components/form.vue";
import { mapGetters, mapActions } from "vuex";
export default {
  components: {
    listVue,
    formVue,
  },
  props: [],
  data() {
    return {
      info: {
        isshow: false,
        isadd: true,
      },
    };
  },
  computed: {
    ...mapGetters({
      list: "specs/list",
      total: "specs/total",
      size: "specs/size",
    }),
  },
  mounted() {
    this.reqList();
    this.reqTotal()
  },
  methods: {
    ...mapActions({
      reqList: "specs/reqList",
      reqTotal: "specs/reqTotal",
      changePage: "specs/changePage",
    }),
    add() {
      this.info.isshow = true;
      this.info.isadd = true;
    },
    willEdit(id) {
      this.info.isshow = true;
      this.info.isadd = false;
      this.$refs.form.getone(id);
    },
  },
};
</script>
<style scoped lang="less">
@import "../../less/index.less";
</style>